<div class="dialog-wrap">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label label-required">确认发票申请</label>
            <div class="layui-input-block" lay-verify-msg="是否同意" lay-verify="mustradio">
                <input type="radio" name="agree" value="0" title="是">
                <input type="radio" name="agree" value="1" title="否">
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" id="saveBtn" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['layer', 'form', 'utils', 'verify'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            form = layui.form,
            utils = layui.utils,
            verify = layui.verify;
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        form.verify({
            mustradio: function (value, item) { //单选按钮必选
                var va = $(item).find("input[type='radio']:checked").val();
                if (typeof (va) == "undefined") {
                    return $(item).attr("lay-verify-msg");
                }
            }
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            utils.Ajax({
                url: '',
                dataType: 'json',
                type: 'post',
                data: data.field,
                success: function (response) {
                    layer.msg(response.message, {time: 1000}, function () {
                        layer.close(parentIndex);
                    })
                }
            });

            return false;
        });


    });

</script>
